﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MyFreecell
{
    public partial class Poker : UserControl
    {
        public Point MouseLocation;
        public int index;//该牌的序数(用来决定牌的正面图)
        public int PaiColor;//牌花色，用来判断是否符合移动标准( 1黑桃，2红桃，3梅花，4方块)
        public int VALUE; //牌的数字值
        public int LieID; //牌所在列
        public Image BackImage;//牌背面图案
        public Image ForeImage;//牌正面
        public Point PaiTuoQianWeiZhi = new Point();//牌位置
        public bool CanMove = false;//该牌是否可以移动,默认不能
        public bool Draged = false;//该牌是否已经移动,默认不能

        public Poker()
        {
            InitializeComponent();
            PaiTuoQianWeiZhi = this.Location;//初始化获得位置
        }
        private void PokePai_MouseEnter(object sender, EventArgs e)
        {
            this.BorderStyle = BorderStyle.None;
            PaiTuoQianWeiZhi = this.Location;
        }

        private void PokePai_MouseLeave(object sender, EventArgs e)
        {
            this.BorderStyle = BorderStyle.FixedSingle;
        }

        private void PokePai_MouseDown(object sender, MouseEventArgs e)
        {
            if (CanMove)
            {
                if (e.Button == MouseButtons.Left)
                {
                    MouseLocation = e.Location;

                    this.BringToFront();
                    this.DoDragDrop(this, DragDropEffects.Move);
                }
            }
        }

        private void PokePai_Resize(object sender, EventArgs e)
        {
            int width = Math.Min(this.Width, this.Height);
            this.Width = width;
            this.Height = 150 * width / 105;
        }
    }
}
